package 每日一题;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

/**
 * @author chenhong
 * @version 1.0.0
 * @ClassName L2357.java
 * @createTime 2023年02月24日 13:22:00
 */
public class L2357 {
    public static void main(String[] args) {
        Solution2357 solution2357 = new Solution2357();
        solution2357.minimumOperations(new int[]{1,5,0,3,5});
    }
}

class Solution2357 {
    //纯暴力
    public int minimumOperations(int[] nums) {
        Arrays.sort(nums);
        int count = 0;
        for (int i = 0; i < nums.length; i++) {
            if(nums[i] != 0 ){
                for(int j = i + 1;j<nums.length;j++){
                    nums[j] -= nums[i];
                }
                nums[i] = 0;
                count++;
            }
        }
        return count;
    }

    public int minimumOperations2(int []nums){
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < nums.length; i++) {
            if(nums[i] != 0)
                set.add(nums[i]);
        }
        return set.size();

    }
}